<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        {{message}}
    </div>
    <div id="app-2">
        <span v-bind:title="message">
            鼠标悬停查看信息!
        </span>
    </div>
    <div id="app-3">
        <p v-if='seen'>就这</p>
    </div>
    <div id="app-4">
        <ol>
            <li v-for="todo in todos">
                {{todo.text}}
            </li>
        </ol>
    </div>
    <div id="app-5">
        <p>{{message}}</p>
        <button v-on:click="reverseMessage">反转</button>
    </div>
    <div id="app-6">
        <p>{{ message }}</p>
        <input v-model="message">
    </div>
</body>

</html>
<script>
    //声明式渲染
    var app = new Vue({
        el: "#app",
        data: {
            message: "hi"
        }
    });
    var app2 = new Vue({
        el: "#app-2",
        data: {
            message: '页面加载于' + new Date().toLocaleString()
        }
    });
    //条件
    var app3 = new Vue({
        el: "#app-3",
        data: {
            seen: true
        }
    });
    //循环
    var app4 = new Vue({
        el: "#app-4",
        data: {
            todos: [{
                text: 'one'
            }, {
                text: 'two'
            }, {
                text: 'three'
            }]
        }
    });
    //事件监听器
    var app5 = new Vue({
        el: "#app-5",
        data: {
            message: 'Hello Vue.js!'
        },
        methods: {
            reverseMessage: function() {
                //this.message = this.message.split('').reverse().join('');
                this.message = this.message.split('').reverse().join('');
            }
        }
    })
    var app6 = new Vue({
        el: '#app-6',
        data: {
            message: 'Hello Vue!'
        }
    })
</script>